#include <iostream> 

using namespace std; 

char get_closed_bracket(char c) {
    if (c == '[')
    {
        return ']';
    }
    else if (c == '(')
    {
        return ')';
    }
    else if (c == '<') 
    {
        return '>';
    }
    else if (c == '{') 
    {
        return '}';
    }
    else {
        return 0; 
    }
}

char stack[1000];
int top = -1; 

bool push(char x) {
    if (top >= 999) { 
        return false;
    } else {
        top++;
        stack[top] = x; 
        return true;
    }
}

char pop() {
    if (top < 0) {
        return 0;
    } else {
        char c = stack[top]; 
        top--;  
        return c; 
    }
}

bool isEmpty() {
    return (top < 0);
}

bool check_brackets(string s) {
    for (char c : s) { 
        if (c == '[' or c == '(' or c == '{' or c == '<') {
            push(c);
        } else {
            char topElement = pop();
            
            if (topElement == 0) { 
                return false; 
            }
            
            if (get_closed_bracket(topElement) != c) {
                return false;
            }
        }
    }
    return isEmpty(); 
}

int main() {
    string s;
    cin >> s;
    cout << (check_brackets(s) ? "True" : "False");
    return 0;
}